package com.work.model.builder;

import java.lang.reflect.ParameterizedType;

import org.jboss.logging.Logger;

/**
 * The Class Builder.
 *
 * @param <T> the generic type
 * @author 860715857
 */
public class Builder<T> {
	
	/** The Constant LOG. */
	private static final Logger LOG = Logger.getLogger(Builder.class);

	/** The t. */
	protected T t;

	/**
	 * Instantiates a new builder.
	 */
	@SuppressWarnings("unchecked")
	public Builder() {
		super();		
		try {
			t = ((Class<T>)((ParameterizedType)this.getClass().getGenericSuperclass()).getActualTypeArguments()[0]).newInstance();
			LOG.info("Create builder for " + t.getClass().getName());
		} catch (IllegalAccessException e) {
			LOG.error("ERROR Create builder for " + t.getClass().getName(),e);
		} catch (InstantiationException e) {
			LOG.error("ERROR Create builder for " + t.getClass().getName(),e);
		}
	}
	
	/**
	 * Builds the.
	 *
	 * @return the t
	 */
	public T build() {
		return t;

	}

}
